package com.sen.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sen.dao.UserDao;
import com.sen.entity.DruginfoEntity;
import com.sen.entity.UserEntity;
import com.sen.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service("userService")
public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements UserService {

    @Autowired
    UserDao userDao;

    @Override
    public IPage<UserEntity> queryAllUser(Map<String, String> user, Page<UserEntity> page) {
        QueryWrapper<DruginfoEntity> wrapper = new QueryWrapper<>();
        if (user.get("name")!=null){
            wrapper.like("name", user.get("name"));
        }
        if (user.get("phone")!=null){
            wrapper.like("phone", user.get("phone"));
        }
        if (user.get("createdate[0]")!=null){
            wrapper.between("createdate", user.get("createdate[0]"),user.get("createdate[1]"));
        }
        return userDao.queryAllUser(page,wrapper);
    }
}
